import 'package:flutter/material.dart';
import '../models/list_item.dart';
//更新列表项组件
class ListItemCard extends StatelessWidget{
  final ListItem item;
  final int index;
  final VoidCallback onTap;
  final VoidCallback onDelete;

  const ListItemCard({
    Key? key,
    required this.item,
    required this.index,
    required this.onTap,
    required this.onDelete,
}):super (key: key);

  @override
  Widget build(BuildContext context) {
      return Card(
        margin: const EdgeInsets.symmetric(horizontal: 16,vertical: 4),
        elevation: 1,
        child: ListTile(
          contentPadding: const EdgeInsets.symmetric( horizontal: 16,vertical: 8),
          leading: Container(
            padding: const EdgeInsets.all(12),
            decoration: BoxDecoration(
              color: item.color.withOpacity(0.15),
              shape: BoxShape.circle
            ),
            child: Icon(item.icon,size: 28,color: item.color),
          ),
          title: Text(item.title,style: const TextStyle(fontSize: 18,fontWeight: FontWeight.w600)),
          subtitle: Text("this is the description of ${item.title} "),
          trailing: Row(
            mainAxisSize: MainAxisSize.min,
            children: [
              IconButton(onPressed: onDelete, icon: const Icon(Icons.delete,color: Colors.red)),
              const Icon(Icons.chevron_right,color: Colors.grey),
            ],
          ),
          onTap:  onTap,
        ),

      );
  }
}